{extend name="public/base" /} {block name="css"}
<link rel="stylesheet" href="__INDEX__/css/create-index.css"> 
<link href="__PLUGIN__/Fileinput/css/fileinput.css" rel="stylesheet">
{/block}
 {block name="container"}
<div>
    <form action="" method="post" enctype="multipart/form-data" onsubmit ="getElementById('submitInput').disabled=true;return true;" >
    <div class="panel-body panel-body-nopadding" id="print">
        <div class="inforMain">客户信息</div>
        <div class="form-groups">
            <label class="col-sm-1 control-label">
                <span>*</span>客户名称：</label>
            <div class="col-sm-6">
                {$data['customer']['name'] ?? ''}
            </div>
        </div>
        <div class="form-groups">
            <label class="col-sm-1 control-label">
                <span>*</span>联系电话：</label>
            <div class="col-sm-6">
                {$data['customer']['phone'] ?? ''}
            </div>
        </div>
        <div class="form-groups">
            <label class="col-sm-1 control-label">
                <span>*</span>性&emsp;&emsp;别：</label>
            <div class="col-sm-6">
                {$data['customer']['sex'] ?? ''}
            </div>
        </div>
        <div class="form-groups">
            <label class="col-sm-1 control-label">
                <span>*</span>年&emsp;&emsp;龄：</label>
            <div class="col-sm-6">
                {$data['customer']['age'] ?? ''}
            </div>
        </div>
        <div class="form-groups" style="padding-bottom: 10px">
            <label class="col-sm-1 control-label">
                <span>*</span>收货地址：</label>
            <div class="col-sm-6">
                {$data['customer']['dizhi'] ?? ''}
            </div>
        </div>


        <div class="form-group">
                <label class="col-sm-12 control-label" style="background: #7F7F7F;text-align: center;color: #000;">订单信息
                    <div style="display: inline-block;background: #7F7F7F;padding-left:200px;font-size: 12px">产品编号:
                        <input type="text" style="background: #7F7F7F;border:0" name="order[pro_num]"  value="" >
                    </div>
                </label>
                <div class="col-sm-12">
                    <table class="table ">
                        <tr>
                            <td>品类</td>
                            <td colspan="8">
                                {volist name="category" id="vo"}
                                <input type="radio" value="{$vo.id}" name="order[category_id]" onclick="get_style_num(this.value)" style="width: auto;" > {$vo.title}
                                {/volist}
                            </td>
                        </tr>
                        <tr>
                            <td>款式编号</td>
                            <td colspan="2">
                                <input type="text" name="order[style_num]"  value="" style="width: 100%" readonly>
                            </td>
                            <td>面料编号</td>
                            <td colspan="2">
                                <input type="text" name="order[ml_num]"  value="" style="width: 100%">
                            </td>
                            <td>订单属性</td>
                             <td colspan="2" style="display: flex;justify-content: center;">
                               <input type="radio" value="1" name="order[shuxing]" style="width: auto;margin-left: 10px;"><p style="color: #676a6c !important;" required>正常订单</p>
                               <input type="radio" value="2" name="order[shuxing]" style="width: auto;"><p style="color: #676a6c !important;" required>售后订单</p>
                             </td>
                        </tr>
                        <tr>
                            <td>款式细节</td>
                            <td colspan="8">
                                <textarea name="order[detail]" id=""  cols="30" rows="10" style="border:0px;width: 100%;outline: none;resize: none;">{$data['detail'] ?? ''}</textarea>
                            </td>
                        </tr>
                                <tr>
            <td>着装风格</td>
            <td colspan="8">
                {volist name="style" id="vo"}
                    <input type="radio" style="display: inline-block;width: auto;" name="order[yifu_style]" value="{$vo.id}" {if condition="$vo['id'] eq 3"} checked {/if}>{$vo.name}
                {/volist}
            </td>
        </tr>
                        <tr>
                            <td>特殊备注</td>
                            <td colspan="4">
                                <input type="text" style="width: 100%;" name="order[comment]"  value="">
                            </td>
                            <td>加急</td>
                            <td colspan="3">
                                <input type="radio" style="display: inline-block;width: auto;"  name="order[is_urgent]" value="1">是
                                <input type="radio" style="display: inline-block;width: auto;" name="order[is_urgent]"  value="0">否
                                <div style="display: inline-block;">加急
                                    <input type="text" style="width: 25px;" name="order[urgent_num]"  value="{$data['urgent_num'] ?? ''}">天</div>
                            </td>
                        </tr>
                        <tr>
                            <td>订单金额</td>
                            <td colspan="1">
                                <input type="text" name="order[price]" value="{$data['price'] ?? ''}" >
                            </td>
                            <td>实付金额</td>
                            <td colspan="1">
                                <input type="text" name="order[true_price]" value="{$data['true_price'] ?? ''}" >
                            </td>
                            <td>是否代加工</td>
                           <td colspan="4" style="padding: 0px;">
                             <input type="radio" class="is_ok" style="display: inline-block;width: auto;padding: 8px 0" name="order[is_dai]" value="1">是
                               <input type="radio" class="is_ok" style="display: inline-block;width: auto;padding: 8px 0" name="order[is_dai]" value="0">否
                               <div style="display: none;float: right;width: 50%;"id="gongchang">选择工厂<select name="order[gongchang]" id="" style="width: 65%;outline: none;margin-left: 10px;border: 0px; ">
                                   <option value="-1">请选择工厂</option>
                                    <option value="1">红岭</option>
                                    <option value="2">如意</option>
                                    <option value="3">鲁泰</option>
                               </select></div>
                           </td>
                        </tr>
                         <tr>
            <td colspan="1">付款方式</td>
            <td colspan="8">
                    <input class="is_dian" type="radio" name="order[payment]" value="1" style="display: inline-block;width: auto;padding: 1px">普通支付
                    <input class="is_dian" type="radio" name="order[payment]" value="0" style="display: inline-block;width: auto;padding: 1px">会员卡支付
                <div style="display: inline-block;">

                    <span id="huiyuan" style="display: none;margin-left: 30px;">
                        卡号：<input type="text" name="order[card_num]" id="card_num" style="display: inline-block;width: auto;padding:1px ">
                        余额：<input type="text" name="order[money]" id="money" readonly style="display: inline-block;width: auto;padding:1px ">
                        密码：<input type="password" name="pass" id="pass" style="display: inline-block;width: auto;padding:1px ">
                    </span>
                </div>
            </td>
        </tr>
                        <tr></tr>
                    </table>
                </div>
            </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">付款凭证：</label>
                        <div class="col-sm-6">
                            <input id="fileone" type="file" class="file-loading">
                            <input type="hidden" id="picurl" placeholder="缩略图" name="order[picurl]" value="{$order.picurl ?? ''}">
                        </div>
                    </div>
    </div>
    <div class="panel-footer">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-3">
                <input type="hidden" name="id" value="">
                <button type="submit" class="btn btn-primary" style="margin:0 auto" id="submitInput"> 提交</button>
            </div>
        </div>
    </div>
    <!-- panel-footer -->
    </form>
</div>
{/block} {block name="js"}
<script src="__PLUGIN__/Fileinput/js/fileinput.js"></script>
<script>
   $(document).ready(function() {
    fileinputOne("fileone","picurl");
   });
</script>
<script>
  function get_style_num(id)
  {
    
    /*通过js获取年份*/
    var myDate = new Date();
    var y = myDate.getFullYear();  //获取当前年份(2位)
    var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
    if(m<10){
      m = '0'+m;
    }
    var d = myDate.getDate();        //获取当前日(1-31)
    var nian =  y+"" + m +""+d;
    nian = nian.substring(2);
    /*获取性别*/
    var sex = "{$data['customer']['sex']}"; 
    
    if(sex == '男'){
      var xing = 'M';
    }else{
      var xing = 'W';
    }
    var str = 'X'+xing+''+nian+'-';
    $.post('{:url("index/order/getStyleNum")}', {id: id}, function(data) {
     var  style_num = str+data;
     $('input:text[name="order[style_num]"]').val(style_num);
    });
  }
</script>
<script>
    function fileinputOne(fileid,field){
      var widths = arguments[2] ? arguments[2] : 'auto';//设置默认的图片宽度
      var heights = arguments[3] ? arguments[3] : '160px';//设置默认的图片高度
      //单图上传
      var $input = $("#"+fileid);
      var $picurl = $("#"+field); 
        
      var $Preview =[];
      var $Config =[];
      if($picurl.val()!=''){
         $Preview =["<img class='kv-preview-data file-preview-image' style='width:"+widths+";height:"+heights+";' src='__ROOT__"+$picurl.val()+"'>"];
         $Config =[{key: 1}];
      }
      $input.fileinput({
          uploadUrl: "{:url('index/common/upload')}",
          deleteUrl: "{:url('index/common/updel')}",
          autoReplace: true,
          overwriteInitial: true,
          showUploadedThumbs: false,
          maxFileCount: 1,
          initialPreview: $Preview,
          initialPreviewConfig: $Config,
          layoutTemplates: {actionDelete: ''}, 
      }).on("filebatchselected", function(event, files) {
          $input.fileinput("upload");//选择后自动上传
      }).on('fileuploaded', function(event, data,previewId,index) {
           //alert(JSON.stringify(data));
           var dataObj=eval("("+data.response+")");
           if(dataObj['code']==0)
             {  
                 $picurl.val(dataObj['img']);
             }
           else{
                swal("出错了", "上传失败,请刷新再试", "error");
             }
      }).on("filecleared", function(event, files) {
             $picurl.val('');
      });

}
</script>
<script>
    function getRegion(val, level) {
        var $city = $("#city");
        var $area = $("#area");
        $.post('{:url('index / common / getRegion')}', { pcode: val, level: level }, function (data) {
            var dataObj = eval("(" + data + ")");//转换为json对象   
            if (dataObj['code'] == 1) {
                if (level == '1') {
                    $.each(dataObj['list'], function (i, item) {
                        $city.append('<option value="' + item['code'] + '">' + item['name'] + '</option>');
                    });
                } else {
                    $.each(dataObj['list'], function (i, item) {
                        $area.append('<option value="' + item['code'] + '">' + item['name'] + '</option>');
                    });
                }
            }
        });
    }
</script>
<script>
    function getInfo(val) {
        var $user_id = $('#user_id');
        $.post('{:url('index / common / getInfo')}', { id: val }, function (data) {
            var dataObj = eval("(" + data + ")");//转换为json对象  
            if (dataObj['code'] == 1) {
                $.each(dataObj['list'], function (i, item) {
                    $user_id.append('<option value="' + item['id'] + '">' + item['truename'] + '</option>');
                });
            }
        });
    }
</script> 
<script>
  
   $(function () {
      $(".is_ok").click(function () {
          if ($(this).val() == 1) {
              //alert("选中了");
              $('#gongchang').css('display','block');
          }else{
            $('#gongchang').css('display','none');
          }
      });
           // 支付方式
      $(".is_dian").click(function(){
          if($(this).val() == 1){
              $('#huiyuan').css('display','none')
          }else{
              $('#huiyuan').css('display','block')
          }
          
      })
          /*检查会员卡是否是系统的卡*/
     $('#card_num').keydown(function(event) {
       if(event.keyCode == '13')
       {
        $.post('{:url("index/member/getMemberInfo")}', {card_num: $('#card_num').val()}, function(data) {
                        if(data.sta ==1)/*正常用户*/
                        {
                            $('#money').val(data.money);
                        }else if(data.sta == 2)
                        {
                            swal({title: '该卡已被冻结',text: "",type: "error"});
                            document.getElementById('card_num').value = '' ; 
                        }else{
                            swal({title: '该卡号不存在',  text: "",type: "error"});
                            document.getElementById('card_num').value = '' ;
                        }
                    });
        return false;
       }
     }); 
     /*会员卡验证密码的功能*/
        $('#pass').bind('keydown', function(event) {
            if(event.keyCode == '13')
            {
                $.post('{:url("index/member/checkPassword")}', {password: $('#pass').val(),card_num: $('#card_num').val()}, function(data) {
                    if(data.sta != 1)
                    {
                       swal({title: '密码输入错误',  text: "",type: "error"}); 
                       document.getElementById('pass').value = '' ;
                       return false;
                    }else{
                        swal({title: '密码正确',  text: "",type: "success"});
                        return false;
                    }
                });
                return false;
            }
        });  
  });
</script>
{/block}

